package cn.modoumama.notice.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.modoumama.common.utils.StringUtils;
import cn.modoumama.notice.entity.ApiMethodCfgModel;
import cn.modoumama.notice.mapper.ApiMethodCfgMapper;
import cn.modoumama.notice.service.ApiMethodCfgService;
import cn.modoumama.service.base.impl.BaseServiceImpl;


/**
* 类名称：ApiMethodCfg对象定义<br>
* 类描述：方法配置表业务实现类<br>
* 类生产方式：工具自动生成代码<br>
* 创建人：dengqiang<br>
* 创建时间：2017-06-16 13:45:31<br>
* 修改人：  <br>
* 修改时间：<br>
* 修改备注：<br>
* @version   V1.0
*/

@Service
@Transactional(value="notice", rollbackFor={Exception.class})
public class ApiMethodCfgServiceImpl extends BaseServiceImpl<ApiMethodCfgModel,Integer> implements ApiMethodCfgService{
	Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	public void setMapper(ApiMethodCfgMapper genericMapper) {
		super.setGenericMapper(genericMapper);
	}

	//------------------请在此添加自定义方法（开始）------------------
	public Integer mergeMethodCfg(ApiMethodCfgModel entity) {
		if(entity != null && entity.getMethodId() != null && StringUtils.isNotBlank(entity.getVer())){
			ApiMethodCfgModel old = new ApiMethodCfgModel();
			old.setMethodId(entity.getMethodId());
			old.setVer(entity.getVer());
			
			old = findObjectByModel(old);
			if(old == null){
				insert(entity);
			}else{
				entity.setId(old.getId());
				updateById(entity);
			}
		}
		return entity.getId();
	}
	//------------------请在此添加自定义方法（结束）------------------
}
